# from app.order.sale.model import SaleOrder as SaleOrderTable
# from app.order.sale.model import SaleOrderSku as SaleOrderSkuTable
#
# from app.order.purchase.abs_model import PurchaseOrder
# from common.constant import OrderType
#
# from app.finance.abs_model import Account
# from app.storage.abs_model import Warehouse, WarehouseRecord
#
#
# class SaleOrder(PurchaseOrder):
#     OrderTableClass = SaleOrderTable
#     OrderSkuTableClass = SaleOrderSkuTable
#     order_sn_prefix = 'XS'
#     order_type = OrderType.SALE
#
#     def _update_warehouse_record_by_submit(self, order_sku_table):
#         """销售 减少数量，不修改成本单价"""
#         warehouse_record = WarehouseRecord(order_sku_table.sku_id, self.order_table.warehouse_id)
#         warehouse_record.add_num(num=-order_sku_table.num)
#
#     def _update_warehouse_record_by_revoke(self, order_sku_table):
#         """销售撤销 增加数量, 不修改成本单价"""
#         warehouse_record = WarehouseRecord(order_sku_table.sku_id, self.order_table.warehouse_id)
#         warehouse_record.add_num(num=order_sku_table.num)
#
#     def _create_warehouse_flow(self, order_sku_table):
#         """销售 减少数量"""
#         warehouse = Warehouse(self.order_table.warehouse_id, self.user_id)
#         warehouse.create_flow(self.user_id, self.order_type, self.id,
#                               order_sku_table.sku_id, -order_sku_table.num)
#
#     def _create_account_flow(self):
#         """销售 应收实收"""
#         should_income = self._calculate_should_income()
#         account = Account(self.order_table.account_id, self.user_id)
#         account.create_flow_by_order(
#             OrderType.SALE, self.id,
#             should_income=should_income,
#             income=self.order_table.income)
#
#     def _calculate_should_income(self):
#         should_income = 0
#         for order_sku_table in self.order_skus_table:
#             should_income += order_sku_table.total_price
#         return should_income
